﻿// Learn more about F# at http://fsharp.net

//define a function and execute it then print the result
let f x = x*x

let result = f(2)

printfn "%d" result

//try a swap function and print the result
let swap (a,b) = (b,a)

let r2 = (3,2)

printfn "%A" r2

let r3 = swap(3,2);

printfn "%A" r3


//define a recursive function
let rec fb a =
    if a > 1 then fb(a-1) * a
    else a
    
let r4 = fb(100)
printfn "%d" r4

//open System
//let stringD = String.Join( " ", [| "A";"B" |] )
//
//printfn "%d" stringD

let listA = []
let listB = [ 1; 2; 3 ]
printfn "%A" listB

let listC = 1 :: [1;2;3]

printfn "%A" listC


type Book = {
    Title: string;
    Author: string;
    Price: double;
    }

let book = {
Title = "Exprt F#";
Author = "Cnaod";
Price = 55.01}

let r6 =  [ for i in 100 .. 1000 -> ( i, i*i) ]
printfn "result = %A " r6


let com2 x = ( x, x * x )
let com3 x = ( x, x*x, x*x*x )
let r7 = [ for i in 1 .. 100 -> com2 i ]
let r8 = [ for i in 1 .. 100 -> com3 i ]
printfn "%A" r7
printfn  "%A" r8